package rad.Java.Common.Util;

import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LogErro
{
    private static String nameFile= "errors.xml";
    private static String sqlFile = "sqlerros.xml";

    public static void writeError(String msg)
    {
        writeFile(nameFile, msg);
    }


    private static void writeErrorSql(String msg)
    {
        writeFile(sqlFile, msg);
    }

    private static void writeFile(String file, String msg)
    {
        SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyy");
        Date data = new Date();
        
        String temp = "-------------------------------------------------------------------------------------------------";

        temp+= "\nData: "+format.format(data);
        //temp+= "\nHora: "+DateTime.Now.ToLongTimeString();
        temp+= "\n"+msg+"\n\n";

        try
        {
            FileWriter writer = new FileWriter(file, true);
            writer.write(temp);
            writer.close();
        }
        catch(IOException e)
        {
            System.out.println(e.toString());
        }

    }
}
